package com.lc1993929.mr.rating.efficienttopn;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * Created by LiuChang on 2017/12/19/019.
 * 自定义分区规则，uid相同就发往同一个reduce task
 */
public class UidPartitioner extends Partitioner<RateBean, NullWritable> {
    @Override
    public int getPartition(RateBean rateBean, NullWritable nullWritable, int i) {
        return rateBean.getUid().hashCode() & Integer.MAX_VALUE % i;
    }
}
